DEF_PROJECT=../../..
include $(DEF_PROJECT)/scripts/main.mk
name=sysvinit
version=2.88dsf
prefix=/usr
destdir=$(DIR_SYSROOT)
extdeps=eglibc-tools gcc-tools binutils-tools linux-header-tools

DL_SERV=http
DL_HOST=download.savannah.gnu.org
DL_PATH=releases/$(name)
DL_SUFFIX=tar.bz2

pre-build:
	cp -nv $</src/Makefile{,.orig}
	sed -e 's@/dev/initctl@$$(ROOT)&@g' \
		-e 's@\(mknod \)-m \([0-9]* \)\(.* \)p@\1\3p; chmod \2\3@g' \
		-e '/^ifeq/s@$$(ROOT)@@' \
		-e 's@/usr/lib@$$(ROOT)&@' \
		-e 's@/dev/initctl ;@& true ;@' \
		$</src/Makefile.orig > $</src/Makefile
	$(MAKE) -C $</src clobber
normal-build:
	LDFLAGS='-lcrypt' $(MAKE) -C $(source)/src ROOT=$(DIR_SYSROOT) CC=$(addsuffix -,$(CC_TARGET))gcc

post-build:
	$(MAKE) -C $(source)/src ROOT=$(DIR_SYSROOT) INSTALL="install" install
	cp $(DIR_ORIG)/inittab $(destdir)/etc/
